package com.kuang.lesson01

import java.net.InetAddress

/**
 * 测试ip
 */
fun main() {
    // 查询本机地址
    println(InetAddress.getByName("127.0.0.1"))
    println(InetAddress.getByName("localhost"))
    println(InetAddress.getLocalHost())
    /*
    /127.0.0.1
    localhost/127.0.0.1
    USER-VFGNDPVELL/192.168.0.16
     */
    println("----------------------")

    //查询网站ip地址
    println(InetAddress.getByName("www.baidu.com")) //www.baidu.com/61.135.169.121
    println("----------------------")

    //常用方法
    InetAddress.getByName("www.baidu.com").apply {
        println(address)    //不重要
        println(canonicalHostName)  //规范名字
        println(hostAddress)    //ip
        println(hostName)   //域名
        /*
        [B@7ea987ac
        61.135.169.121
        61.135.169.121
        www.baidu.com
         */
    }
}